package edu.kaist.cs442.client.android.common.location.track;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;
import edu.kaist.cs442.client.android.common.RestServices;
import edu.kaist.cs442.client.android.common.notification.NotificationBar;
import edu.kaist.cs442.client.android.common.pushutil.register.TrackInstallation;

/**
 * Created with IntelliJ IDEA.
 * User: duyleekun
 * Date: 4/18/12
 * Time: 11:12 PM
 * To change this template use File | Settings | File Templates.
 */
public class TrackLocationListener implements LocationListener {

	Context currentContext;

	public TrackLocationListener(Context currentContext) {
		this.currentContext = currentContext;
	}

	@Override
	public void onLocationChanged(Location location) {
		Log.i("location",String.format("Lat = %f Long = %f",location.getLatitude(),location.getLongitude()));
		NotificationBar.send(this.currentContext,1,"just update location","just update location", "just update location");
		RestServices.getTrackerSVC().updateLocation(TrackInstallation.id(currentContext),location.getLatitude(),location.getLongitude());
	}

	@Override
	public void onStatusChanged(String s, int i, Bundle bundle) {
		Log.i("location","on status changed");
	}

	@Override
	public void onProviderEnabled(String s) {
		Log.i("location","on provider enabled");
	}

	@Override
	public void onProviderDisabled(String s) {
		Log.i("location","on provider disabled");
	}
}
